package OperationSystem.MultiplyThread;

public class GetThreadMainField {
    public static void PutThreadField() {
        Thread thread=new Thread();
        long id = thread.getId();
        System.out.println(id+":线程的唯一标识：" + id);//类似于进程的pid
        String name = thread.getName();
        System.out.println(id+":线程的名字：" + name);
        int priority=thread.getPriority();
        System.out.println(id+":线程的优先级:"+priority);
        Thread.State state=thread.getState();
        System.out.println(id+":线程当前的状态:"+state);
        boolean alive=thread.isAlive();
        System.out.println(id+":线程当前是否还活着:"+alive);
        boolean interrupted = thread.isInterrupted();
        System.out.println(id+":线程是否被中断了:"+interrupted);
        boolean daemon = thread.isDaemon();
        System.out.println(id+":线程是否是后台线程:"+daemon);
    }
    public static void main(String[] args) {
        /*
        Thread thread = new Thread();//因为没有重写过run方法，所以线程什么都不做就退出了
        long id = thread.getId();
        System.out.println("线程的唯一标识：" + id);//类似于进程的pid
        String name = thread.getName();
        System.out.println("线程的名字：" + name);
        int priority=thread.getPriority();
        System.out.println("线程的优先级:"+priority);
        Thread.State state=thread.getState();
        System.out.println("线程当前的状态:"+state);
        boolean alive=thread.isAlive();
        System.out.println("线程当前是否还活着:"+alive);
        boolean interrupted = thread.isInterrupted();
        System.out.println("线程是否被中断了:"+interrupted);
        boolean daemon = thread.isDaemon();
        System.out.println("线程是否是后台线程:"+daemon);
        */

        Thread thread=new Thread(()->{
            PutThreadField();
        },"张三");
        thread.start();

        Thread thread1=new Thread(()->{
            PutThreadField();
        },"李四");
        thread1.start();

        PutThreadField();
    }
}
